package com.controller;

import com.common.Result;
import com.entity.User;
import com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * User的路由接口服务
 * 
 * @author 
 *
 */
@RestController
@RequestMapping("user")
public class UserController {

	/** UserService服务 */
	@Autowired
	private UserService userService;

	/**
	 * 通过id查询User数据的方法
	 * @param id
	 * @return
	 */
	@GetMapping(value = "/user/{id}", produces = {"application/json;charset=UTF-8"})
	public User findOne(@PathVariable(name="id") String id) {
		return userService.findOne(id);
	}

	/**
	 * 新增User数据的方法
	 * @param id
	 * @return
	 */
	@PostMapping(value = "/user/{id}", produces = {"application/json;charset=UTF-8"})
	public Result create(@RequestBody User user) {
		return userService.create(user);
	}

}
